B18 - Subset Sum with Restoration
提出
code: python
n, s = map(int, input().split())
a = list(map(int, input().split()))
# 2 2 3
# dpij := i 枚までで合計 j にできるか dp = [0 * (s+1) for _ in range(n+1)] for j in range(1, s+1):
for i in range(1, n+1):
for j in range(s+1):
else:
while True:
if
解答
code: python
n, s = map(int, input().split())
a = list(map(int, input().split()))
# 2 2 3
# dpij := i 枚までで合計 j にできるか dp = [0 * (s+1) for _ in range(n+1)] for j in range(1, s+1):
for i in range(1, n+1):
for j in range(s+1):
else:
print("-1")
exit()
ans = []
p = s
for i in reversed(range(1,n+1)):
# カード i を選ばない
p = p - 0
# カード i を選ぶ
else:
ans.append(i)
ans.reverse()
print(len(ans))
print(" ".join(ans2))